<?php

declare(strict_types=1);

namespace App\Constants\Order;

use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
use function Hyperf\Translation\__;

#[Constants]
class OrderCode extends AbstractConstants
{
    const STATUS_PENDING_PAID = 1;

    const STATUS_PENDING_DELIVERY = 2;

    const STATUS_PENDING_RECEIVED = 3;

    const STATUS_RECEIVED = 4;

    const STATUS_COMPLETE = 5;

    const STATUS_CANCEL = 6;

    const STATUS_CLOSE = 7;

    const PAY_STATUS_PENDING_PAID = 1;

    const PAY_STATUS_PART_PAID = 2;

    const PAY_STATUS_PAID = 3;

    const PAY_STATUS_PART_REFUND = 4;

    const PAY_STATUS_REFUND = 5;

    const PAY_STATUS_APPLY_REFUND = 6;

    const PAY_STATUS_REFUSE_REFUND = 7;

    const SOURCE_MINI = 'mini';

    const SOURCE_PC = 'pc';

    /**
     * 来源映射
     * @var array|string[]
     */
    public static array $sourceMap = [
        self::SOURCE_MINI,
        self::SOURCE_PC
    ];

    /**
     * 获取状态描述
     * @param int $value
     * @return string
     */
    public static function getStatusMessage(int $value):string
    {
        return match ($value) {
            self::STATUS_PENDING_PAID => __('model.order.status.pending_paid'),
            self::STATUS_PENDING_DELIVERY => __('model.order.status.pending_delivery'),
            self::STATUS_PENDING_RECEIVED => __('model.order.status.pending_received'),
            self::STATUS_RECEIVED => __('model.order.status.received'),
            self::STATUS_COMPLETE => __('model.order.status.complete'),
            self::STATUS_CANCEL => __('model.order.status.cancel'),
            self::STATUS_CLOSE => __('model.order.status.close')
        };
    }

    /**
     * 获取支付状态
     * @param int $value
     * @return string
     */
    public static function getPayStatusMessage(int $value):string
    {
        return match ($value) {
            self::PAY_STATUS_PENDING_PAID => __('model.order.pay_status.pending_paid'),
            self::PAY_STATUS_PART_PAID => __('model.order.pay_status.part_paid'),
            self::PAY_STATUS_PAID => __('model.order.pay_status.paid'),
            self::PAY_STATUS_PART_REFUND => __('model.order.pay_status.part_refund'),
            self::PAY_STATUS_REFUND => __('model.order.pay_status.refund'),
            self::PAY_STATUS_APPLY_REFUND => __('model.order.pay_status.apply_refund'),
            self::PAY_STATUS_REFUSE_REFUND => __('model.order.pay_status.refuse_refund')
        };
    }
}
